{extends file="../home.html"}
{block name="title"}{$head_title}{/block}
{block name="css"}
<!-- <link rel="stylesheet" style="text/css" href="__PUBLIC__/Css/front/user_glb.css?version={$version}"> -->

<style type="text/css">
    body{
    	padding-top:2.2rem;
    }
    .company_intro{
    	width:100%;
    	resize:none;
    	height:6rem;
    	font-size:0.8rem;
    }
</style>
{/block}
{block name="content"}
{include file="../common_header.html"}
<form>
<h6 class="bei">企业信息</h6>
<ul class="visit_from" style="margin-top:0;">
    <li class="clearfix">
        <label for="yin" class="fl">企业名称</label>
        <input type="text" id="yin" name="service_providers_name" value="" placeholder="请输入企业名称">
    </li>
    <li class="clearfix">
        <label for="name" class="">企业LOGO</label>
        <div class="up_img_box fl logo_upload">
            <a href="javascript:;" class="add icon fl icon_upload_default3x" title="上传一张新的图片" id="add_upload"></a>
            <input type="hidden" name="service_providers_logo" class="img_url" id="img_url" />
        </div>
        <div class="preview preview_logo fl clearfix img_html"></div>
    </li>
</ul>
<ul class="visit_from">
    <li class="clearfix">
        <label for="jian" class="fl">企业简称</label>
        <input type="text" id="jian" name="enterprise_name" value="" placeholder="请输入企业简称">
    </li>
    <li class="clearfix">
        <label for="business" class="fl">主营业务</label>
        <input type="text" id="business" name="business" value="" placeholder="请输入主营业务">
    </li>
    <li class="clearfix">
        <label class="fl">类别选择</label>
        <select name="service_type_id" id="service_type_id">
            <option value="">请选择类别</option>
            {foreach from=$service_type_list item = type}
            <option value="{$type.service_type_id}">{$type.service_type_name}</option>
            {/foreach}
        </select>
        <i class="fr icon icon_enter_default3x"></i>
    </li>
    <li class="clearfix">
        <label for="website" class="fl">公司网址</label>
        <input type="text" id="website" name="url" value="http://" placeholder="请输入公司网址">
    </li>
    <li class="clearfix">
        <label class="fl">所在省份</label>
        <select id="province_id" name="province_id">
        	<option value="">--选择省份--</option>
            {foreach from = $province_list item =this}
            <option value="{$this.province_id}">{$this.province_name}</option>
            {/foreach}
    	</select>
    </li>
    <li class="clearfix">
        <label class="fl">所在城市</label>
        <select id="city_id" name="city_id">
        	<option value="">--选择城市--</option>
    	</select>
    </li>
    <li class="clearfix">
        <label class="fl">所在地区</label>
        <select id="area_id" name="area_id">
        	<option value="">--选择地区--</option>
    	</select>
    </li>
    <li class="clearfix">
        <label class="fl">企业简介</label>
        <textarea class="company_intro" name="service_providers_describe" id="service_providers_describe"></textarea>
    </li>
    <li class="clearfix">
        <label for="tell" style="width:60%;">三合一证或营业执照</label>
        <div class="up_img_box fl logo_upload">
            <a href="javascript:;" class="add icon fl icon_upload_default3x" title="上传一张新的图片" id="add_upload1"></a>
            <input type="hidden" name="charter" class="img_url" id="img_url1" />
        </div>
        <div class="preview preview_three fl clearfix img_html"></div>
    </li>
</ul>
<h6 class="bei">联系人信息</h6>
<ul class="visit_from" style="margin-top:0;">
    <li class="clearfix">
        <label for="ceo" class="fl">企业负责人</label>
        <input type="text" id="ceo" name="enterprise_user_name" value="" placeholder="请输入企业负责人">
    </li>
    <li class="clearfix">
        <label for="phone" class="fl">负责人手机</label>
        <input type="number" id="phone" name="enterprise_user_mobile" value="" placeholder="请输入手机号">
    </li>
    <li class="clearfix">
        <label for="contacts" class="fl">联系人</label>
        <input type="text" id="contacts" name="user_name" value="" placeholder="请输入联系人">
    </li>
    <li class="clearfix">
        <label for="contacts_phone" class="fl">联系人手机</label>
        <input type="number" id="contacts_phone" name="mobile" value="" placeholder="请输入联系人手机">
    </li>
    <li class="clearfix">
        <label for="contacts_email" class="fl">联系人邮箱</label>
        <input type="text" id="contacts_email" name="email" value="" placeholder="请输入联系人邮箱">
    </li>
    <li class="clearfix">
        <label for="contacts_address" class="fl">联系人地址</label>
        <input type="text" id="contacts_address" name="address" value="" placeholder="请输入地址">
    </li>
</ul>
<h6 class="bei">公众号信息</h6>
<ul class="visit_from" style="margin-top:0;margin-bottom:2.65rem;">
    <li class="clearfix">
        <label for="code" class="fl">公众号</label>
        <input type="text" id="code" name="accounts" value="" placeholder="请输入公众号">
    </li>
    <li class="clearfix">
        <label for="name" class="">公众号二维码</label>
        <div class="up_img_box fl logo_upload">
            <a href="javascript:;" class="add icon fl icon_upload_default3x" title="上传一张新的图片" id="add_upload2"></a>
            <input type="hidden" name="accounts_code" class="img_url" id="img_ur2" />
        </div>
        <div class="preview preview_code fl clearfix img_html"></div>
    </li>
</ul>
</form>
<div class="submit_btn">提交</div>
{/block}
{block name="js"}

<!-- <script type="text/javascript" src="__PUBLIC__/Js/front/iscroll.js"></script> -->
<script src="__ACPJS__/AcpServiceProviders/linkage.js?version={$version}"></script>
<script type="text/javascript" src="/Public/Js/front/front_js/ajaxupload.3.5.js"></script>
        <script type="text/javascript">
                //分享的参数
    var share_pic = '/Public/Images/front/front_img/logo_default3x.png';
    var share_title = '银江孵化器';
    var desc_str = '申请服务商';
    var share_desc = desc_str.substr(0,30);
    var share_url = document.location.href;
{literal}
            $(function()
            {
//                $(".service_header i,.service_header span").on("click",function()
//                {
//                    history.go(-1);
//                });
                $(".submit_btn").on("click",function()
                {
                    if($("#yin").val()=='')
                    {
                        layer.open({
                            content: '请输入企业名称',
                            title: false,
                            btn: ['确定'],
                        });
                        return;
                    }
                    if($("#jian").val()=='')
                    {
                        layer.open({
                            content: '请输入企业简称',
                            title: false,
                            btn: ['确定'],
                        });
                        return;
                    }
                    if($("#business").val()=='')
                    {
                        layer.open({
                            content: '请输入公司主营业务',
                            title: false,
                            btn: ['确定'],
                        });
                        return;
                    }
                    if($("#service_type_id").val()=='')
                    {
                        layer.open({
                            content: '请选择类别',
                            title: false,
                            btn: ['确定'],
                        });
                        return;
                    }
                    if($("#website").val()=='')
                    {
                        layer.open({
                            content: '请输入公司网址',
                            title: false,
                            btn: ['确定'],
                        });
                        return;
                    }
                    if($("#province_id").val()=='')
                    {
                        layer.open({
                            content: '请选择省份',
                            title: false,
                            btn: ['确定'],
                        });
                        return;
                    }
                    if($("#city_id").val()=='')
                    {
                        layer.open({
                            content: '请选择城市',
                            title: false,
                            btn: ['确定'],
                        });
                        return;
                    }
                    if($("#area_id").val()=='')
                    {
                        layer.open({
                            content: '请选择区域',
                            title: false,
                            btn: ['确定'],
                        });
                        return;
                    }
                    if($("#service_providers_describe").val()=='')
                    {
                        layer.open({
                            content: '请输入企业简介',
                            title: false,
                            btn: ['确定'],
                        });
                        return;
                    }
                    if($("#ceo").val()=='')
                    {
                        layer.open({
                            content: '请输入企业负责人',
                            title: false,
                            btn: ['确定'],
                        });
                        return;
                    }
                    if($("#phone").val()=='')
                    {
                        layer.open({
                            content: '请输入负责人手机号',
                            title: false,
                            btn: ['确定'],
                        });
                        return;
                    }
                    if($("#contacts").val()=='')
                    {
                        layer.open({
                            content: '请输入联系人',
                            title: false,
                            btn: ['确定'],
                        });
                        return;
                    }
                    if($("#contacts_phone").val()=='')
                    {
                        layer.open({
                            content: '请输入联系人手机',
                            title: false,
                            btn: ['确定'],
                        });
                        return;
                    }
                    if($("#contacts_email").val()=='')
                    {
                        layer.open({
                            content: '请输入联系人邮箱',
                            title: false,
                            btn: ['确定'],
                        });
                        return;
                    }
                    if($("#contacts_address").val()=='')
                    {
                        layer.open({
                            content: '请输入地址',
                            title: false,
                            btn: ['确定'],
                        });
                        return;
                    }
                    if($("#code").val()=='')
                    {
                        layer.open({
                            content: '请输入公众号',
                            title: false,
                            btn: ['确定'],
                        });
                        return;
                    }
                    $.ajax({
                        type: 'POST',
                        url: '/FrontService/apply_service_providers' ,
                        data: $('form').serialize(),
                        success:function(data) {
                            if(data.status == 0 ){
                                layer.open({
                                    content: data.msg,
                                    title: false,
                                    btn: ['确定'],
                                    yes:function(){
                                        if(!is_wechat()){
                                            native_listen('back');
                                        }else{
                                            history.go(-1);
                                        }
                                    }
                                });
                               // location.href ="/FrontService/get_providers_list";
                            }else{
                                layer.open({
                                    content: data.msg,
                                    title: false,
                                    btn: ['确定'],
                                });
//                                alert(data.msg);
                            }
                        }
                    })
                });
        //企业logo
                $(".preview_logo").on("click",".del_img",function(){
                    if($(this).parents(".preview").find('img').length==1){
                        $(this).parents(".img_html").siblings('.img_url').val('');      
                    }
                    $(this).parent(".img_box").remove();
                    $("#add_upload").parent().css("display","block");
                })
                // 上传图片
                new AjaxUpload("#add_upload", {
                action: "/Front/uploadHandler",
                name: "upfile",
                responseType: "json",
                onSubmit: function(){
                        //alert('正在上传');
                        //preview处的图片改为loading图片
                        /*$('.preview').show();
                        if($("#add_upload").siblings('.preview').find('img').length>=10){
                            alert("最多上传10张图片");
                            return false;
                        }*/
                    },
                    onChange: function(file, extension){
                        if (extension && /^(jpg|png|jpeg|gif)$/.test(extension)) {
                            return true;
                        }
                        else {
                            //alert('暂不支持该图片格式！');
                            layer.open({
                                    content: '暂不支持该图片格式！',
                                    title: false,
                                    btn: ['确定'],
                                });
                            return false;
                        }
                    },
                    onComplete: function(file, response){
                    //  console.log(response);
                        if (response.status === 0) {
                            layer.open({
                                    content: response.msg,
                                    title: false,
                                    btn: ['确定'],
                                });
                        }
                        else if (response.status === 1) {
                            var html;
                            html='<div class=" fl img_box"><img class="pic-preview" src="'+response.img_url+'"/><div class="del_img"></div></div>';
                            $('.preview_logo').append(html);
                            // $("#add_upload").siblings('.preview').show();
                            $("#img_url").val(response.img_url);
                            $("#add_upload").parent().css("display","none");
                        }
                        
                    }
                });
        //三合一证或营业执照
                $(".preview_three").on("click",".del_img",function(){
                        if($(this).parents(".preview").find('img').length==1){
                            $(this).parents(".img_html").siblings('.img_url').val('');      
                        }
                        $(this).parent(".img_box").remove();
                        $("#add_upload1").parent().css("display","block");
                    })
                    // 上传图片
                    new AjaxUpload("#add_upload1", {
                    action: "/Front/uploadHandler",
                    name: "upfile",
                    responseType: "json",
                    onSubmit: function(){
                            //alert('正在上传');
                            //preview处的图片改为loading图片
                            $('.preview').show();
                            /*if($("#add_upload1").siblings('.preview').find('img').length>=10){
                                alert("最多上传10张图片");
                                return false;
                            }*/
                        },
                        onChange: function(file, extension){
                            if (extension && /^(jpg|png|jpeg|gif)$/.test(extension)) {
                                return true;
                            }
                            else {
                                //alert('暂不支持该图片格式！');
                                layer.open({
                                    content: '暂不支持该图片格式！',
                                    title: false,
                                    btn: ['确定'],
                                });
                                return false;
                            }
                        },
                        onComplete: function(file, response){
                        //  console.log(response);
                            if (response.status === 0) {
                                //alert(response.msg);
                                layer.open({
                                    content: response.msg,
                                    title: false,
                                    btn: ['确定'],
                                });
                            }
                            else if (response.status === 1) {
                                var html;
                                html='<div class=" fl img_box"><img class="pic-preview" src="'+response.img_url+'"/><div class="del_img"></div></div>';
                                $('.preview_three').append(html);
                                // $("#add_upload").siblings('.preview').show();
                                $("#img_url1").val(response.img_url);
                                $("#add_upload1").parent().css("display","none");
                            }
                            
                        }
                    });
                });
        //公众号二维码
                $(".preview_code").on("click",".del_img",function(){
                        if($(this).parents(".preview").find('img').length==1){
                            $(this).parents(".img_html").siblings('.img_url').val('');      
                        }
                        $(this).parent(".img_box").remove();
                        $("#add_upload2").parent().css("display","block");
                    })
                    // 上传图片
                    new AjaxUpload("#add_upload2", {
                    action: "/Front/uploadHandler",
                    name: "upfile",
                    responseType: "json",
                    onSubmit: function(){
                            //alert('正在上传');
                            //preview处的图片改为loading图片
                            /*$('.preview').show();
                            if($("#add_upload2").siblings('.preview').find('img').length>=10){
                                alert("最多上传10张图片");
                                return false;
                            }*/
                        },
                        onChange: function(file, extension){
                            if (extension && /^(jpg|png|jpeg|gif)$/.test(extension)) {
                                return true;
                            }
                            else {
                                //alert('暂不支持该图片格式！');
                                layer.open({
                                    content: '暂不支持该图片格式！',
                                    title: false,
                                    btn: ['确定'],
                                });
                                return false;
                            }
                        },
                        onComplete: function(file, response){
                        //  console.log(response);
                            if (response.status === 0) {
                                alert(response.msg);
                            }
                            else if (response.status === 1) {
                                var html;
                                html='<div class=" fl img_box"><img class="pic-preview" src="'+response.img_url+'"/><div class="del_img"></div></div>';
                                $('.preview_code').append(html);
                                // $("#add_upload").siblings('.preview').show();
                                $("#img_ur2").val(response.img_url);
                                $("#add_upload2").parent().css("display","none");
                            }
                            
                        }
                    });
        </script>
{/literal}
{/block}